<style>
    table{

        table-layout:fixed;/* 只有定义了表格的布局算法为fixed，下面td的定义才能起作用。 */
    }
    td{
        width:100%;
        word-break:keep-all;/* 不换行 */
        white-space:nowrap;/* 不换行 */
        overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */
        text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用。*/
    }
</style>
<p style="margin-left:20px;">专题基本信息</p>
<br>
<form class="layui-form">
    <div class="layui-form-item">
        <label class="layui-form-label">专题分类</label>
        <div class="layui-input-block" style="width:350px;">
            <?php if(in_array($data['sub_title'],['小央拜年助手','网春大拜年',"超级测测测","超级配配配"])){ ?>
                <select name="sub_type" lay-verify="required" class="sub_type layui-disabled" disabled>
                    <?php if(!empty($type)){
                        foreach($type as $k=>$v){
                            ?>
                            <?php if($v['id']==$data['sub_type']){ ?>
                                <option value="<?=$v['id']?>" selected><?=$v['name']?></option>
                            <?php }else{ ?>
                                <option value="<?=$v['id']?>"><?=$v['name']?></option>
                            <?php } ?>
                        <?php }} ?>
                </select>
            <?php }else{ ?>
                <select name="sub_type" lay-verify="required" class="sub_type">
                    <?php if(!empty($type)){
                        foreach($type as $k=>$v){
                            ?>
                            <?php if($v['id']==$data['sub_type']){ ?>
                                <option value="<?=$v['id']?>" selected><?=$v['name']?></option>
                            <?php }else{ ?>
                                <option value="<?=$v['id']?>"><?=$v['name']?></option>
                            <?php } ?>
                        <?php }} ?>
                </select>
            <?php } ?>

        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">话题</label>
        <div class="layui-input-inline">
            <?php if(in_array($data['sub_title'],['小央拜年助手','网春大拜年',"超级测测测","超级配配配"])){ ?>
                <input type="text" name="title" value="<?=$data['sub_title']?>" placeholder="请输入话题" class="layui-input sub_title layui-disabled" style="width:200px;" disabled>
            <?php }else{ ?>
                <input type="text" name="title" value="<?=$data['sub_title']?>" placeholder="请输入话题" class="layui-input sub_title" style="width:200px;">
            <?php } ?>

        </div>
        <span style="margin-left: 10px;margin-top: 5px;color: gainsboro;">最大字数5</span>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">封面</label>
        <div class="layui-input-block">
            <button type="button" class="layui-btn" id="test1">上传封面</button>
            <br>
            <br>
            <input type="hidden" value="<?=$data['sub_pic']?>" class="sub_pic">
            <div style="width:100px;height:100px;border:1px solid darkseagreen;float: left;" >
                <img src="<?=$data['sub_pic']?>" style="width:100px;height: 100px;" class="image">
            </div>
            <span style="margin-left: 10px;color: gainsboro;">建议尺寸750*280</span>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">话题简介</label>
        <div class="layui-input-inline" style="float: left;">
            <textarea name="desc" placeholder="请输入简介" class="layui-textarea sub_desc" style="width: 300px;"><?=$data['sub_desc']?></textarea>
        </div>
        <span style="margin-left: 10px;margin-top: 5px;color: gainsboro;">最大字数50</span>
    </div>
    <div class="layui-form-item layui-form-text">
        <input type="hidden" value="<?=$data['id']?>" class="ids">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <button class="layui-btn save" type="button">保存</button>
            <!--            <button class="layui-btn back" type="button">返回</button>-->
        </div>
    </div>
</form>
<br>
<hr class="layui-bg-black">
<p>话题管理</p>
<hr class="layui-bg-black">
<form class="layui-form" id="search-form">
    <div style="min-height: 38px;margin-top: 5px;">
        <div class="layui-inline">
            <div class="layui-input-inline">
                <select name="online_select" lay-filter="online_select" id="online_select">
                    <option value="">上线状态</option>
                    <option value="2" >已上线</option>
                    <option value="1">已下线</option>
                </select>
            </div>
        </div>
        <div class="layui-inline" style="float: right;">
            <div class="layui-input-inline">
                <!--               <button type="button" class="layui-btn add_jinpin">添加精品内容</button>-->
                <input type="hidden" value="<?=$type_sub_id?>" class="fenlei_id_type">
            </div>
        </div>
    </div>
</form>
<!--------------------------------------------------------------不是默认话题的显示---------------------------------------------------------------------------->
<?php if($data['is_other']!=999999999){ ?>
    <table class="layui-table">
        <colgroup>
            <col width="8%">
            <col width="10%">
            <col width="20%">
            <col width="15%">
            <col width="6%">
            <col width="7%">
            <col width="20%">
        </colgroup>
        <thead>
        <tr>
            <th>视频id</th>
            <th>缩略图</th>
            <th>视频标题</th>
            <th>上传时间</th>
            <th>排序</th>
            <th>上线状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <?php if(!empty($data1['row'])){
            foreach($data1['row'] as $a=>$b){
                ?>
                <tr>
                    <td><?=$b['id']?></td>
                    <td>
                        <img src="<?=$b['pic']?>" style="width:100px;height:100px;" class="video<?=$a+1;?>">
                        <input type="hidden" value="<?=$b['video_url']?>" class="content<?=$a+1;?>">
                    </td>
                    <td ><?=$b['video_desc']?></td>
                    <td><?=$b['add_time']?></td>
                    <?php if(empty($b['type_sub_order']) || $b['type_sub_order']==999999999 || $b['type_sub_order']==9999999999){ ?>
                        <td>0</td>
                    <?php }else{ ?>
                        <td><?=$b['type_sub_order']?></td>
                    <?php } ?>
                    <?php if($b['examine']==1){ ?>
                        <td>下线</td>
                    <?php }else if($b['examine']==2){ ?>
                        <td>待审核</td>
                    <?php }else if($b['examine']==3){ ?>
                        <td>上线</td>
                    <?php } ?>
                    <td>
                        <input type="hidden" value="<?=$b['id']?>" class="video_uuid<?=$a+1?>">
                        <input type="hidden" value="<?=$b['join_type_sub']?>" class="join_type_sub<?=$a+1?>">
                        <?php if($b['join_type_sub']==1){ ?>
                            <a href="<?=base_url("word/words/edit_sort?id={$b['id']}")?>" class="layui-btn layui-btn-xs">编辑</a>
                        <?php }else{ ?>
                            <a href="<?=base_url("word/words/edit_sort?id={$b['id']}")?>" class="layui-btn layui-btn-xs">编辑</a>
                            <?php if($b['examine']==1){ ?>
                                <button class="layui-btn layui-btn-xs layui-btn-warm up<?=$a+1?>">上线</button>
                            <?php }else if($b['examine']==2){ ?>
                                <button class="layui-btn layui-btn-xs layui-btn-warm up<?=$a+1?>">上线</button>
                            <?php }else if($b['examine']==3){ ?>
                                <button class="layui-btn layui-btn-xs layui-btn-normal sort<?=$a+1?>">排序</button>
                                <button class="layui-btn layui-btn-xs layui-btn-danger down<?=$a+1?>">下线</button>
                            <?php } ?>
                            <button class="layui-btn layui-btn-xs move<?=$a+1?>">移出话题</button>
                        <?php } ?>
                    </td>
                </tr>
            <?php }} ?>
        </tbody>
    </table>
<?php }else{ ?>
    <table class="layui-table">
        <colgroup>
            <col width="8%">
            <col width="10%">
            <col width="20%">
            <col width="7%">
            <col width="7%">
            <col width="13%">
            <col width="7%">
            <col width="7%">
            <col width="20%">
        </colgroup>
        <thead>
        <tr>
            <th>视频id</th>
            <th>缩略图</th>
            <th>视频标题</th>
            <th>原分类</th>
            <th>原话题</th>
            <th>上传时间</th>
            <th>排序</th>
            <th>上线状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <?php if(!empty($data1['row'])){
            foreach($data1['row'] as $a=>$b){
                ?>
                <tr>
                    <td><?=$b['id']?></td>
                    <td>
                        <img src="<?=$b['pic']?>" style="width:100px;height:100px;" class="video<?=$a+1;?>">
                        <input type="hidden" value="<?=$b['video_url']?>" class="content<?=$a+1;?>">
                    </td>
                    <td ><?=$b['video_desc']?></td>
                    <td ><?=$b['old_join_type']?></td>
                    <td ><?=$b['old_join_type_sub']?></td>
                    <td><?=$b['add_time']?></td>
                    <?php if(empty($b['type_sub_order']) || $b['type_sub_order']==999999999 || $b['type_sub_order']==9999999999){ ?>
                        <td>0</td>
                    <?php }else{ ?>
                        <td><?=$b['type_sub_order']?></td>
                    <?php } ?>
                    <?php if($b['examine']==1){ ?>
                        <td>下线</td>
                    <?php }else if($b['examine']==2){ ?>
                        <td>待审核</td>
                    <?php }else if($b['examine']==3){ ?>
                        <td>上线</td>
                    <?php } ?>
                    <td>
                        <input type="hidden" value="<?=$b['id']?>" class="video_uuid<?=$a+1?>">
                        <input type="hidden" value="<?=$b['join_type_sub']?>" class="join_type_sub<?=$a+1?>">
                        <?php if($b['join_type_sub']==1){ ?>
                            <a href="<?=base_url("word/words/edit_sorts?id={$b['id']}")?>" class="layui-btn layui-btn-xs">编辑</a>
                        <?php }else{ ?>
                            <a href="<?=base_url("word/words/edit_sort?id={$b['id']}")?>" class="layui-btn layui-btn-xs">编辑</a>
                            <?php if($b['examine']==1){ ?>
                                <button class="layui-btn layui-btn-xs layui-btn-warm up<?=$a+1?>">上线</button>
                            <?php }else if($b['examine']==2){ ?>
                                <button class="layui-btn layui-btn-xs layui-btn-warm up<?=$a+1?>">上线</button>
                            <?php }else if($b['examine']==3){ ?>
                                <button class="layui-btn layui-btn-xs layui-btn-normal sort<?=$a+1?>">排序</button>
                                <button class="layui-btn layui-btn-xs layui-btn-danger down<?=$a+1?>">下线</button>
                            <?php } ?>
                            <button class="layui-btn layui-btn-xs move<?=$a+1?>">移出话题</button>
                        <?php } ?>
                    </td>
                </tr>
            <?php }} ?>
        </tbody>
    </table>
<?php } ?>
<!-------------------------------------------------------------------默认话题的显示------------------------------------------------------------------------------------>
<div id="demo7"></div>
<table id="demo" lay-filter="test"></table>

<script src="<?=SITE_BASE_URL?>/assets/plugins/dyj/layui_url.js"></script>

<script>
    //定义一个51的jquery数组
    var arr=[];
    for(var i=1;i<51;i++){
        arr.push(i)
    }
    $.each(arr,function(i,n) {
        var video_uuid = $(".video_uuid" + n).val();
        //排序
        $(".sort" + n).click(function () {
            $.ajax({
                type: "post",
                data: {video_uuid: video_uuid},
                dataType: "json",
                url: "<?=base_url("word/words/sort")?>",
                success: function (res) {
                    if (res.code == 0) {
                        layui.use('layer', function () {
                            var layer = layui.layer;
                            layer.open({
                                title: "排序",
                                type: 1,
                                area: ['500px', '300px'],
                                content: res.data //注意，如果str是object，那么需要字符拼接。
                                , btn: ['保存', '取消']
                                , yes: function (index, layero) {
                                    var paixu = $(".edit_paixu").val()
                                    //按钮【按钮一】的回调
                                    $.ajax({
                                        type: "post",
                                        data: {paixu: paixu, video_uuid: video_uuid},
                                        dataType: "json",
                                        url: "<?=base_url("word/words/save_sort")?>",
                                        success: function (res) {
                                            if (res.code == 0) {
                                                layer.msg(res.msg, {time: 1000}, function () {
                                                    window.location.reload()
                                                });
                                            } else {
                                                layer.msg(res.msg, {time: 2000});
                                            }
                                        }
                                    })
                                }
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    close(index)
                                }
                                , cancel: function () {
                                    //右上角关闭回调

                                }
                            });
                        });
                    } else {
                        layer.msg(res.msg, {time: 2000});
                    }
                }
            })
        })
        //上线
        $(".up" + n).click(function () {
            $.ajax({
                type: "post",
                data: {video_uuid: video_uuid},
                dataType: "json",
                url: "<?=base_url("word/words/up_sort")?>",
                success: function (res) {
                    if (res.code == 0) {
                        layer.msg(res.msg, {time: 1000}, function () {
                            window.location.reload()
                        });
                    } else {
                        layer.msg(res.msg, {time: 2000});
                    }
                }
            })
        })
        //下线
        $(".down" + n).click(function () {
            $.ajax({
                type: "post",
                data: {video_uuid: video_uuid},
                dataType: "json",
                url: "<?=base_url("word/words/down_sort")?>",
                success: function (res) {
                    if (res.code == 0) {
                        layer.msg(res.msg, {time: 1000}, function () {
                            window.location.reload()
                        });
                    } else {
                        layer.msg(res.msg, {time: 2000});
                    }
                }
            })
        })
        //移出话题
        $(".move" + n).click(function () {
            var join_type_sub = $(".join_type_sub" + n).val();
            $.ajax({
                type: "post",
                data: {video_uuid: video_uuid,join_type_sub: join_type_sub},
                dataType: "json",
                url: "<?=base_url("word/words/move_sort")?>",
                success: function (res) {
                    if (res.code == 0) {
                        layer.msg(res.msg, {time: 1000}, function () {
                            window.location.reload()
                        });
                    } else {
                        layer.msg(res.msg, {time: 2000});
                    }
                }
            })
        })

        //移入缩略图显示和隐藏小手
        $('.video'+n).mouseover(function(){
            $(this).css("cursor","pointer")
        }).mouseout(function(){
            $(this).css("cursor","")
        })
        //视频放大
        $('.video'+n).click(function(){
            var content=$('.content'+n).val();
            var html="";
            html+="<video src='"+content+"' style=\"width:560px;height:400px;\" controls='controls' autoplay></video>"
            layer.open({
                title:'视频播放'
                ,content: html
                ,area:['600px','540px']
                ,btn: ['关闭']
                ,yes: function(index, layero){
//按钮【按钮一】的回调
                    layer.close(index)
                }
                ,cancel: function(){
//右上角关闭回调

//return false 开启该代码可禁止点击该按钮关闭
                }
            });
        })
    })

    $(function(){
        //隐藏动态表格
        //添加精品内容
        $('.add_jinpin').on("click",function(){
            var type_id=$('.fenlei_id_type').val()
            layui.use('layer', function(){
                var layer = layui.layer;
                layer.open({
                    type: 2,
                    area:["90%","600px"],
                    content: 'table?type_id='+type_id,
                    success: function(layero, index){

                    },
                    cancel: function(){
                        //右上角关闭回调
                        window.location.reload()
                    }
                });
            });
        })

        //保存数据
        $('.save').click(function(){
            var ids=$('.ids').val();
            var sub_type=$('.sub_type').val();
            var sub_title=$('.sub_title').val();
            var sub_pic=$('.sub_pic').val();
            var sub_desc=$('.sub_desc').val();
            var a=[sub_type,sub_title,sub_pic,sub_desc]
            $.ajax({
                type: "post",
                data: {sub_type:sub_type,sub_title:sub_title,sub_pic:sub_pic,sub_desc:sub_desc,id:ids},
                dataType: "json",
                url: "<?=base_url("word/words/save_edit_word")?>",
                success: function (res) {
                    if(res.code==0){
                        layer.msg(res.msg, {time: 1000},function(){
                            window.location.href="<?=base_url("word/words/index")?>"
                        });
                    }else{
                        layer.msg(res.msg, {time: 2000});
                    }
                }
            })
        })

        //上传封面
        layui.use('upload', function(){
            var upload = layui.upload;
            //执行实例
            var uploadInst = upload.render({
                elem: '#test1' //绑定元素
                , url: "<?=base_url("common/upload/normal_upload")?>"
                , data: {type: "image"}
                ,acceptMime: 'image/*'
                ,done: function(res){
                    //上传完毕回调
                    if(res.code==0){
                        layer.msg(res.msg,{time:1000},function(){
                            $('.image').attr("src",res.data.file_url)
                            $('.sub_pic').val(res.data.file_url)
                        })
                    }else{
                        layer.msg(res.msg,{time:2000})
                    }
                }
            });
        });

        //分页
        layui.use('laypage', function(){
            var laypage = layui.laypage;
            var param = GetRequest();
            //总页数大于页码总数
            laypage.render({
                elem: 'demo7'
                ,count:<?=$data1['total']?>//数据总数
                ,curr: <?=$page?>
                ,limit:<?=$limit?>
                ,layout:  ['count', 'prev', 'page', 'next','limit', 'refresh', 'skip']
                ,jump: function(obj,first){
                    //首次不执行
                    if(!first){
                        var url = window.location.href;
                        url = url.substring(0, url.lastIndexOf('?'));

                        param['page'] = obj.curr;
                        param['limit'] = obj.limit;
                        window.location.href = createURL(url,param);
                    }
                }
            });
        });

        //返回
        $(".back").click(function(){
            history.go(-1)
        })
    })

</script>